package com.hgd.action;

import java.util.List;
import java.util.Map;

import com.hgd.client.init.InitImplDelegate;
import com.hgd.client.init.InitImplService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ConfigurationAction extends ActionSupport{
	
	private Integer adminId;
	private int R;
	private int LOOP;
	InitImplService service = new InitImplService();
	InitImplDelegate delegate = service.getInitImplPort();
	
	ActionContext context = ActionContext.getContext(); 
	Map params = context.getParameters(); 

	public String dispatchCfg() throws Exception{
		params = context.getParameters(); 
		String[] id=(String[])params.get("adminId");
		adminId = Integer.parseInt(id[0]);
		List<Integer> dispatchList =  delegate.dispatchCfg(adminId);
		
		R = dispatchList.get(0);
		LOOP = dispatchList.get(1);
		return SUCCESS;
	}
	
	public String setDispatchCfg() throws Exception{
		Map<String, Object> session = ActionContext.getContext().getSession();
		adminId = (Integer) session.get("userId");
		
		List<Integer> dispatchList =  delegate.setDispatchCfg(adminId, R, LOOP);
		
		R = dispatchList.get(0);
		LOOP = dispatchList.get(1);
		
		return SUCCESS;
	}
	
	public Integer getAdminId() {
		return adminId;
	}

	public void setAdminId(Integer adminId) {
		this.adminId = adminId;
	}


	public int getR() {
		return R;
	}

	public void setR(int r) {
		R = r;
	}

	public int getLOOP() {
		return LOOP;
	}

	public void setLOOP(int lOOP) {
		LOOP = lOOP;
	}
	
}
